Repository navigation
[GH-3545] Store ISO WKB in GeoParquet files - #3558
Merged
Merged
Conversation
The GeoParquet writer marked a Z coordinate with the EWKB flag bit of the type word. The GeoParquet specification asks for the WKB of the OGC and ISO standards, which uses the type codes 1001 to 1007 instead. The writer now converts the type words of every geometry it stores, including collection members and geometries nested in other columns. Geometries without Z and the geo metadata are unchanged.
The GeoParquet writer converted each geometry with a Z coordinate to ISO WKB through a second array of the same size. The WKB writer already returns a new array without an SRID, so the type words are now rewritten in that array by the new PublicWkbHeaderAdapter.toIsoWkbInPlace. toIsoWkb is unchanged for its other callers. A geometry collection keeps the coordinate layout of each member, so a collection with XY and XYZ members is stored with the type codes of both. The tutorials now say that Sedona writes the Z dimension with ISO type codes and describe this limit, and a test pins the stored codes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes GeoParquet writer stores XYZ geometries with the EWKB Z flag instead of ISO WKB type codes #3545What changes were proposed in this PR?
The GeoParquet writer stored a geometry with a Z coordinate as EWKB: the type word of
POINT Z (1 2 3)was0x80000001. The GeoParquet specification asks for the WKB of the OGC and ISO standards, where the type code of that point is 1001.The writer now rewrites the type words of each geometry with
PublicWkbHeaderAdapter.toIsoWkbInPlaceand leaves the coordinates as they are. This new method changes the type words in the array the WKB writer returned, so the conversion allocates no second array. The existingtoIsoWkb, which returns a copy, is unchanged for its other callers. This applies to every geometry thegeoparquetformat writes, on all supported Spark versions: root geometry columns, the members of collections, and geometries nested in other columns.What stays the same:
0x80000007, 2 and0x80000001before. ISO WKB asks for Z members throughout such a collection, and Spark's native geometry type rejects it. The documentation now states this limit.geometadata.geometry_typeswas already derived from the declared layout and still is; it now reads the ISO type code.How was this patch tested?
GeoParquetDimensionsSuitehas two new tests that compare the stored bytes with hand-built ISO WKB: one for a point, a point with Z, a line with Z, a multipoint with Z and a geometry collection with Z members in a root column, and one for a geometry inside an array and inside a struct. The existing write test of that suite now also checks the type code of every geometry it writes. All of them fail without the change, because the stored type word carries the EWKB flag. A third new test pins the stored type codes of a collection with XY and XYZ members.The new
PublicWkbHeaderAdapterSuitecoverstoIsoWkbInPlace: it returns the array it was given with ISO type words, for a single geometry and for nested collections in both byte orders, leaves XY and ISO input untouched, returns a new array for WKB with an embedded SRID, and rejects invalid WKB without changing it.The GeoParquet suites pass locally on Spark 4.1 / Scala 2.13, Spark 3.5 / Scala 2.12 and Spark 4.2 / Scala 2.13 (including the GeoParquet suites of the
spark-4.2module).Did this PR include necessary documentation updates?